{extend name=".././view/list.html" /}
{block name="jsset"}
{/block}
{block name="nav"}
<span class="layui-breadcrumb">
  <a href="">考试管理</a>
  <a href="">更多操作</a>
  <a href="">成绩查看</a>
  <a href="">各班级成绩统计表</a>
  <a><cite>{$list['webtitle']}</cite></a>
</span>
{/block}
{block name="search"}
<div class="layui-form-item">
  <label for="searchval" class="layui-form-label">
    关键字
  </label>
  <div class="layui-input-block">
    <input type="text" id="searchval" name="searchval" autocomplete="off" class="layui-input">
  </div>
</div>
<div class="layui-form-item">
  <label for="xueqi_id" class="layui-form-label" class="layui-input">学期</label>
  <div class="layui-input-block">
    <select name="xueqi_id" id="xueqi_id">
    </select>
  </div>
</div>
<div class="layui-form-item">
  <label for="category_id" class="layui-form-label">考试类型</label>
  <div class="layui-input-block">
    <select name="category_id" id="category_id">
    </select>
  </div>
</div>
<div class="layui-form-item">
  <div class="layui-inline">
    <label for="title" class="layui-form-label">
      <span class="x-red">*</span>考试时间
    </label>
    <div class="layui-input-inline">
      <input type="text" class="layui-input" id="bfdate" name="bfdate" placeholder="起始：默认一年前的今天" value="{$list.data.bfdate|default=''}" autocomplete="off" lay-filter="riqi">
    </div>
    <div class="layui-input-inline">
      <input type="text" class="layui-input" id="enddate" name="enddate" placeholder="结束：默认明天" value="{$list.data.enddate|default=''}" autocomplete="off" lay-filter="riqi">
    </div>
  </div>
</div>
<input type="hidden" name="student_id" value="{$list.student_id}">
<div class="layui-form-item" style="text-align: right;">
  <button class="layui-btn" lay-filter="searchSubmit" lay-submit="">搜索</button>
</div>
{/block}
{block name="table"}
<table id="tabledemo" lay-filter="mytable" lay-size="sm"></table>
{/block}
{block name="echart"}
{volist name="$list.sbj" id="vo"}
<div class="layui-col-xs6" style="width:100%; height:400px; margin-top: 45px; margin-bottom: 45px;" id="{$vo.lieming}"></div>
{/volist}
{/block}
{block name="myjs"}
<!-- 表格上面按钮模板 -->
<script type="text/html" id="toolbarDemo">
  <!--   <div class="layui-btn-container">
    <button class="layui-btn" lay-event="download">
      <i class="layui-icon layui-icon-download-circle"></i> 下载报告
    </button>
  </div> -->
</script>
<!-- 记录操作按钮模板 -->
<script type="text/html" id="barDemo">
  <a class="layui-btn-xs" lay-event="detail" title="查看"><i class="layui-icon layui-icon-search"></i></a>
</script>
<!-- 表格操作 -->
<script>
// 提交搜索条件后重载表格
layui.use(['table', 'mytable', 'laydate', 'element', 'form', 'myEchart', 'createInput'], function() {
  var table = layui.table,
    mytable = layui.mytable,
    laydate = layui.laydate,
    form = layui.form,
    element = layui.element,
    cInput = layui.createInput,
    echart = layui.myEchart;

  cInput.categorySelect('xueqi_id', 108);
  cInput.categorySelect('category_id', 109);

  // 设置列
  options.cols = [
    [ //表头
      { field: 'id', type: 'numbers', sort: true, width: 50, title: '序号' }, { field: 'id', title: '操作', toolbar: '#barDemo', minWidth: 10 }, { field: 'kaoshiTitle', sort: true, title: '考试类型', minWidth: 100 }, {
        field: 'bfdate',
        title: '考试时间',
        sort: true,
        minWidth: 150,
        templet: function(d) {
          var date;
          date = d.enddate.split('-');
          endate = date[1] + '-' + date[2];
          endate = d.bfdate + '～' + endate;
          return endate;
        }
      }, { field: 'zuzhi_id', title: '组织单位', sort: true, minWidth: 100 }
    ]
  ];

  var xk = '<?php echo json_encode($list["sbj"]);?>';
  xk = eval(decodeURIComponent(xk));
  for (x in xk) {
    options.cols[0].push({ field: xk[x].lieming, title: xk[x].title, minWidth: 100, sort: true });
  }
  options.cols[0].push({ field: 'avg', title: '平均分', minWidth: 100, sort: true });
  options.cols[0].push({ field: 'sum', title: '总分', minWidth: 100, sort: true });

  // 获取筛选条件并加载表格
  options.where = form.val("search");
  userTable = table.render(options); //获取数据并渲染

  //开始时间
  laydate.render({
    elem: '#bfdate',
    type: 'datetime',
    trigger: 'click', //采用click弹出
    format: 'yyyy-M-d', //可任意组合
  });
  //结束时间
  laydate.render({
    elem: '#enddate',
    type: 'datetime',
    trigger: 'click', //采用click弹出
    format: 'yyyy-M-d', //可任意组合
  });

  // 监听表单提交
  form.on('submit(srcsubmit)', function(data) {
    options.where = lForm.val("search");
    table.render(options); //获取数据并渲染
    getDefenlv();
    return false;
  });


  getDefenlv();


  //监听行工具条
  table.on('tool(mytable)', function(obj) {
    var data = obj.data; //获得当前行数据
    var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
    var tr = obj.tr; //获得当前行 tr 的DOM对象
    switch (layEvent) {
      case 'detail': // 查看
        xadmin.open(obj.data.kaoshiTitle + '考试成绩', '/kaohao/index/read/' + obj.data.kaohao_id, '', '', true);
        break;
    };
  });

  // 条形统计图--平均分
  function getDefenlv() {
    val = form.val('search');
    for (x in xk) {
      val.subject_id = xk[x].id;
      echart.zhexian(xk[x].lieming, '/tools/onestudentchengji/xkold', val, xk[x].title);
    }
  }

});

</script>
{/block}
